package com.example.dashuju.controller;

import com.example.dashuju.service.SalesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api")
@CrossOrigin(origins = "*") // 允许跨域访问
public class DataController {

    @Autowired
    private SalesService salesService;

    @GetMapping("/sales/category")
    public Map<String, Object> getCategorySales() {
        return salesService.getCategorySales();
    }

    @GetMapping("/sales/region")
    public Map<String, Object> getRegionSales() {
        return salesService.getRegionSales();
    }

    @GetMapping("/sales/platform-trend")
    public Map<String, Object> getPlatformTrend() {
        return salesService.getPlatformTrend();
    }

    @GetMapping("/sales/key-regions")
    public Map<String, Object> getKeyRegionsSales() {
        return salesService.getKeyRegionsSales();
    }

    @GetMapping("/sales/region-ratio")
    public Map<String, Object> getCoreRegionsRatio() {
        return salesService.getCoreRegionsRatio();
    }

    @GetMapping("/user/age-distribution")
    public Map<String, Object> getAgeDistribution() {
        return salesService.getAgeDistribution();
    }

    @GetMapping("/user/occupation-distribution")
    public Map<String, Object> getOccupationDistribution() {
        return salesService.getOccupationDistribution();
    }

    @GetMapping("/user/interest-distribution")
    public Map<String, Object> getInterestDistribution() {
        return salesService.getInterestDistribution();
    }

    @GetMapping("/sales/yearly")
    public Map<String, Object> getYearlySales() {
        return salesService.getYearlySales();
    }
}